package com.dsj.gxrd.modules.controller.activity;

import com.dsj.gxrd.modules.activity.domain.entity.RdOverview;
import com.dsj.gxrd.modules.activity.domain.vo.RdOverviewVo;
import com.dsj.gxrd.modules.activity.service.RdOverviewService;
import com.github.pagehelper.PageInfo;
import com.ruoyi.common.core.web.controller.BaseController;
import com.ruoyi.common.core.web.domain.AjaxResult;
import com.ruoyi.common.core.web.page.TableDataInfo;
import com.ruoyi.common.security.annotation.RequiresPermissions;
import io.swagger.annotations.Api;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;


/**
 * @author songpin566
 * @date 2023/09/14
 **/
@RestController
@Api("人大概况")
@RequestMapping("/overview")
public class RdOverviewController extends BaseController {

    @Autowired
    private RdOverviewService rdOverviewService;

    @RequiresPermissions("overview:list")
    @GetMapping("/list")
    public AjaxResult list(String name,String isPublish,String rdBookCatId,Integer pageNum,Integer pageSize) {
        PageInfo<RdOverviewVo> list = rdOverviewService.selectOverviewList(name,isPublish,rdBookCatId,pageNum,pageSize);
        return AjaxResult.success("查询成功").put("rows",list.getList()).put("total",list.getTotal());
    }

    @RequiresPermissions("overview:add")
    @PostMapping()
    public AjaxResult add(@RequestBody RdOverview overview) {
        return toAjax(rdOverviewService.insertOverview(overview));
    }

    @RequiresPermissions("overview:edit")
    @PutMapping()
    public AjaxResult edit(@RequestBody RdOverview overview) {
        return toAjax(rdOverviewService.updateOverview(overview));
    }

    @RequiresPermissions("overview:del")
    @DeleteMapping("/{ids}")
    public AjaxResult removes(@PathVariable List<Long> ids) {
        return rdOverviewService.removes(ids);
    }

    @RequiresPermissions("overview:query")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable Long id)
    {
        RdOverview rdOverview=rdOverviewService.getInfo(id);
        return success(rdOverview);
    }


}
